﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace idleQuest2010
{
    public class Avatar         //holds all attributes of the player character
    {
        public int hp;
        public int maxhp;
        public int mp;
        public int maxmp;
        public int attack;
        public int magic;
        public int defense;
        public int level;
        public int exp;
        public int gold;
        public int invCount;
        public const int MAX_INV = 30;

        public Avatar()
        {   //initialize attributes to starting values
            hp = 8;
            maxhp = 8;
            mp = 3;
            maxmp = 3;
            attack = 1;
            magic = 1;
            defense = 0;
            level = 1;
            exp = 0;
            gold = 0;
            invCount = 0;
        }

        public void initAttribs()
        {//initialize attributes to starting values
            hp = 8;
            maxhp = 8;
            mp = 3;
            maxmp = 3;
            attack = 1;
            magic = 1;
            defense = 0;
            level = 1;
            exp = 0;
            gold = 0;
            invCount = 0;
            System.Console.Out.WriteLine("Player attributes intialized.");
        }

        public void heal()      //restore hp/mp
        {
            hp = maxhp;
            mp = maxmp;
        }

        public void saveAvatar(BinaryWriter gameSave)   //save player
        {
            gameSave.Write(hp);
            gameSave.Write(maxhp);
            gameSave.Write(mp);
            gameSave.Write(maxmp);
            gameSave.Write(attack);
            gameSave.Write(magic);
            gameSave.Write(defense);
            gameSave.Write(level);
            gameSave.Write(exp);
            gameSave.Write(gold);
            gameSave.Write(invCount);
        }

        public void loadAvatar(BinaryReader gameLoad)   //load player
        {
            hp = gameLoad.ReadInt32();
            maxhp = gameLoad.ReadInt32();
            mp = gameLoad.ReadInt32();
            maxmp = gameLoad.ReadInt32();
            attack = gameLoad.ReadInt32();
            magic = gameLoad.ReadInt32();
            defense = gameLoad.ReadInt32();
            level = gameLoad.ReadInt32();
            exp = gameLoad.ReadInt32();
            gold = gameLoad.ReadInt32();
            invCount = gameLoad.ReadInt32();
        }
    }
}
